﻿@model Retete.ViewModels.RaportProductieViewModel
@{
    ViewBag.Title = "Vanzari";
}

<script src="@Url.Content("~/Scripts/jquery-1.4.4.min.js")" type="text/javascript"></script>
<script src="@Url.Content("~/Scripts/jquery-ui.min.js")" type="text/javascript"></script>

<script type="text/javascript">
    $(function () {
        $("#Data").datepicker({ dateFormat: 'mm/dd/yy' });
    });

    function filtreaza() {
        form.submit();
    }
    function exportExcel() {
        ExportExcel.value = true;
        form.submit();
    }
</script>

@using (Html.BeginForm(null, null, FormMethod.Post, new { id = "form", name = "form" }))
{
    <table style="width: 100%">
        <tr>
            <td style="width: 190px; vertical-align: top; border-right-style: dashed; border-right-color: #CFCFCF; border-right-width: 1px;">
                <fieldset>
                    <legend>Activitati</legend>

                    <p class="toolbox"><a href="javascript:exportExcel()">Tiparire</a></p>
                </fieldset>
            </td>
            <td style="vertical-align: top;">
                @Html.HiddenFor(element => element.ExportExcel)

                <fieldset>
                    <legend>Configurare raport</legend>

                    <p>
                        @Html.LabelFor(element => element.Data, "Data:")
                        @Html.TextBoxFor(element => element.Data, new { style = "width: 194px" })
                    </p>

                    <p>
                        @Html.LabelFor(element => element.Data, " ")
                        <a onclick="filtreaza()" href="#">Genereaza raport</a>
                    </p>
                </fieldset>

                <fieldset>
                    <legend>Raport de productie</legend>

                    <table class="grid">
                        <thead>
                            <tr>
                                <th style="width: 70px">Cod</th>
                                <th>Produs</th>
                                <th style="width: 100px">Stoc initial</th>
                                <th style="width: 100px">Cumparat</th>
                                <th style="width: 100px">Vandut</th>
                                <th style="width: 100px">Stoc final</th>
                            </tr>
                        </thead>
                        <tbody>
                            @if (Model.Elemente != null)
                            {
                                for (int i = 0; i < Model.Elemente.Count; i++)
                                {
                                    <tr>
                                        <td>
                                            @Model.Elemente[i].Cod
                                            @Html.HiddenFor(element => element.Elemente[i].Cod)
                                        </td>
                                        <td>
                                            @Model.Elemente[i].Produs
                                            @Html.HiddenFor(element => element.Elemente[i].Produs)
                                        </td>
                                        <td>
                                            @Model.Elemente[i].StocInitial.ToString("0.00", System.Globalization.CultureInfo.InvariantCulture)
                                            @Html.HiddenFor(element => element.Elemente[i].StocInitial)
                                        </td>
                                        <td>
                                            @Model.Elemente[i].CantitateCumparata.ToString("0.00", System.Globalization.CultureInfo.InvariantCulture)
                                            @Html.HiddenFor(element => element.Elemente[i].CantitateCumparata)
                                            @Html.HiddenFor(element => element.Elemente[i].PretCumparare)
                                        </td>
                                        <td>
                                            @Model.Elemente[i].CantitateVanduta.ToString("0.00", System.Globalization.CultureInfo.InvariantCulture)
                                            @Html.HiddenFor(element => element.Elemente[i].CantitateVanduta)
                                            @Html.HiddenFor(element => element.Elemente[i].PretVanzare)
                                        </td>
                                        <td>
                                            @Model.Elemente[i].StocFinal.ToString("0.00", System.Globalization.CultureInfo.InvariantCulture)
                                            @Html.HiddenFor(element => element.Elemente[i].StocFinal)
                                        </td>
                                    </tr>
                                }
                            }
                        </tbody>
                    </table>
                </fieldset>
            </td>
        </tr>
    </table>
}